home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.19970929-19971216
/
000217_news@newsmaster….columbia.edu _Fri Oct 31 10:22:43 1997.msg
< prev
next >
Wrap
Internet Message Format
|
1997-12-15
|
8KB
Return-Path: <news@newsmaster.cc.columbia.edu>
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.35.30])
by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id KAA25426
for <kermit.misc@watsun.cc.columbia.edu>; Fri, 31 Oct 1997 10:22:43 -0500 (EST)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id KAA13623
for kermit.misc@watsun; Fri, 31 Oct 1997 10:22:42 -0500 (EST)
Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
Newsgroups: comp.protocols.kermit.misc
Subject: Re: Need help with Kermit script
Date: 31 Oct 1997 15:22:40 GMT
Organization: Columbia University
Lines: 152
Message-ID: <63ct40$kht$1@apakabar.cc.columbia.edu>
References: <3458A6ED.F555C0D0@alliedsignal.com>
NNTP-Posting-Host: watsun.cc.columbia.edu
Xref: news.columbia.edu comp.protocols.kermit.misc:7999
In article <3458A6ED.F555C0D0@alliedsignal.com>,
John M. Ritter <jmr@snowhite.mto.allied.com> wrote:
: I am trying, for the first time, to write a script that logs onto a
: service and captures data to a file using C-Kermit 6.0.192, 6 Sep 96,
: for UnixWare 2. There are a few things that are confusing me, and I'd
: appreciate some pointers.
:
: 1. Since this will run on different systems in different directories,
: via cron, a shell script kicks off the session with:
: kermit -E -H -l /dev/term/a08m -b 38400 -m usrobotics -y ./.kermitrc
:
: The problem is, if the first command is DIAL phone-number, kermit
: complains: Sorry, you must SET MODEM first
: Huh? if I SHOW MODEM, everything is OK. Why can't I jump right in
: to a dial command? Of course, if I manually SET MODEM, then it
: complains Sorry, you must SET LINE first (and ditto for SPEED).
:
The initialization file is executed before the command-line options (page
462, "Using C-Kermit", 2nd Ed.). So you should not be using your
initialization file as an application-specific script. Call it something
else, like "xx.ksc" and then:
kermit xx.ksc -E -H -l /dev/term/a08m -b 38400 -m usrobotics
: 2. This service is accessed via SprintNet. After connecting to the
: service, I get trampled with escape codes to clear the screen, change
: text colors and dozens of backspaces. The login prompt looks like:
:
: 999999 CONNECTED^M
: ^[[2J^H^H^H^H ^[[6n^[[5n^[[0c^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H
: ^H^H^H^H^H^H^H^H^H^H^H^H^H ^[[12h^H^H^H^H^H
: ^H^H^H^H^H^H^H
: ^[[32m^H^H^H^H^H^H^H^H ^M
: ^M
: 311061100020 14400:8T 128x2,PTRA W002-R5020200#0012 CONNECTED^M
: ^[[31m^H^H^H^H^H ^M
: WE AUTHORIZE USE OF THIS SERVICE ONLY THROUGH EXPRESS WRITTEN PERMISSION.
: ^MUNAUTHORIZED ACCESS OR USE IS A VIOLATION OF LAW. ^[[37m^H^H^H^H^H
: ^M
: ENTER COMPANY ID?^MENTER COMPANY ID? (company id gets entered here)
: ENTER USER ID?BBBBBBBBBBBBBBBBB^MENTER USER ID?XXXXXXXXXXXXXXXXX^MENTER
: USER
: ID?^MENTER USER ID? (user id gets entered here)
:
: Using the examples from the book (See? I bought the book!! Both
: editions too!) and a plain INPUT, I never seem to find the prompt.
:
What does your INPUT statement look like?
: What seems to work fairly well is clearing the buffer and performing
: a \Frindex on \v(input), but the escape codes *still* end up getting
: back to either the kermit command prompt or a UNIX prompt.
:
To explain this, I would need to see your script, but read on...
: There must be a simpler way to scan for this pattern!
:
I'll try to explain. The script language is designed to handle a sequential
stream of input, like when you are logging in to UNIX. It does not (yet)
incorporate any form of ex-post-facto screen scraping (HLLAPI-style
scripting), in which fragments may be painted in any order, which is
impossible in any case in a Kermit version that does not incorporate a
terminal emulator (thus, we might be able to add screen-scraping functions
to K95, but not to UNIX C-Kermit).
But that does not mean you can't use it to handle formatted screens; it just
takes a bit of ingenuity. The trick is to analyze the input to see if there
is anything you can identify that indicates that it has stopped sending you
stuff, as in the IBM Mainframe fullscreen login example on pp.438-439. In
this case we have to wait until the mainframe says "READY", and then we can
send our stuff.
I can't tell from your transcript above whether "ENTER USER ID?" is the last
thing that SprintNet sends before you are to send your login string. In any
case I can see that it sends this prompt more than once. So it is very
likely that Sprintnet is NOT ready for you to send your user ID until after
it sends the LAST COPY of this prompt -- if indeed the prompt is the last
thing it sends.
So the exact form your script takes, again, depends on exactly what
SprintNet is sending. If it sends "ENTER USER ID?" three times and then
waits, then you need four INPUT commands for that string (in series or in
a loop). Sometimes a PAUSE is needed before you send your response, to give
the host sufficient time to turn the direction of transmission around.
Based purely on the transcript above, and just guessing at the timings
involved, I'd suggest something like this:
input 30 ENTER COMPANY ID? ; Wait for first COMPANY ID prompt
if fail (do something)
input 5 ENTER COMPANY ID? ; Now get the second one
if fail (do something)
pause 1 ; Wait a sec
output (company ID)\13 ; Now send the company ID
And then something similar with the USER ID prompt.
Another approach is suggested on page 426 -- the SET INPUT SILENCE command.
This lets you tell Kermit to wait until the host stops transmitting. This
way you don't have to depend on or hardwire the exact number of repeated
prompts into your script.
input 30 ENTER COMPANY ID? ; Wait for first COMPANY ID prompt.
if fail (do something)
set input silence 10 ; Wait for 10 seconds of silence.
while success { input 1 } ; Gobble stuff up.
; Get here after 10 seconds of silence
output (company ID)\13 ; Now send the company ID.
set input silence 0 ; Remove the silence criterion.
Experiment with these techniques and see if you have better luck.
: 3. The section "Downloading to C-Kermit" has an example of grabbing a
: lasagna recipe, but only gives a hint on automating it. I tried to
: get back to a kermit prompt from a script using OUTPUT \v(escape)C
: (Why isn't this listed in the table of built-in variables??)
:
Because it isn't a built-in variable.
: ... and do the log session, but when all is done, the session log file
: is zero bytes.
:
We try to explain this in the documentation (e.g. see pages 419-420). When a
script is running, the CONNECT command is NOT running. There is no escaping
back in a script. Kermit is *already* at its "command prompt".
: Does anybody have an example of this that actually works?
:
When capturing files without Kermit protocol in a script you need to specify
the completion criterion, and it better be something that does not appear in
the file itself. Let's say your host prompt is dollar sign followed by space
on the left margin, i.e. preceded by CR and LF, and the host command to
display a file is "type", and the filename is (what else) oofa.txt.
output type oofa.txt ; Send the command but no carriage return.
clear device ; So its echo doesn't go in the log.
log session oofa.log ; Start the log.
output \13 ; Now send the carriage return.
input 300 {\13\10$ } ; And wait for the system prompt.
if fail (do something)
close session ; Close the session log.
That should do it, provided the file does not contain CR LF $ SP. If it
does -- well, Kermit has no way of knowing whether this sequence comes from
the file or is the system prompt. If you wanted to allow for that case,
the script becomes slightly more involved (use INPUT in a loop to search
for CRLF, write each line to a WRITE FILE, and SET INPUT SILENCE as your
completion criterion).
Does this help?
- Frank